/*
 * TitleList.cpp
 *
 *  Created on: 6 May 2010
 *      Author: Savramis Sartios
 */

#include "TitleList.h"
#include "../../../Exceptions/NullPointer.h"
#include "../../../Domain/TitleList/Iterator/TitleIterator.h"

TitleList::TitleList() {
	/*list_ = new map<string*,string*>;*/

}

TitleList::~TitleList() {
	/*delete list_;*/
}

bool TitleList::add(const string *code,const string *title){
	if((0!=code)&&(0!=title)){
		list_.insert(pair<string*,string*>(const_cast<string*>(code),const_cast<string*>(title)));
		return true;
	}
	throw NullPointer("code can't be null");
}

int TitleList::count()const{
	return list_.size();
}

string * TitleList::getElement(const string *code)const{
	if(0!=code){
		return list_.find(const_cast<string*>(code))->second;
	}
	throw NullPointer("code can't be null");
}

ITitleListIterator *	TitleList::getIterator(){
	ITitleListIterator *it=new TitleIterator((ITitleList *)this);
	return it;
}

map<string*,string*>::iterator TitleList::getStart(){
	return list_.begin();
}
